package pattern.factory_method.basic;

public class CarFactory {
    public static Car createCar(String type) {
        if ("BenChi".equals(type)) {
            return new BenChi();
        } else if ("BaoShiJie".equals(type)){
            return new BaoShiJie();
        } else if ("FaLaLi".equals(type)) {
            return new FaLaLi();
        } else {
            return null;
        }
    }
    /**
     * @Author WLJ
     * @Description //TODO 升级版工厂类
     * @Date 10:45 2023/2/28
     * @Param [clazz]
     * @return pattern.factory_method.basic.Car
     **/
    public static Car createCar(Class<? extends Car> clazz) throws Exception {
        if (clazz != null) {
            return clazz.newInstance();
        }
        return null;
    }
}
